Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 31, 2025

This PR removes the timezonefinder dependency that was automatically looking up timezones based on latitude/longitude coordinates in the Location class.

Problem

The timezonefinder dependency alone is 50M+ in size and depends on numpy (another 16M+), resulting in a total bloat of 66M+ for a feature with no known users. This large dependency size also prevents pre-built binaries from being available for ARM platforms.

Solution

  • Removed dependency: Removed timezonefinder >= 6.2.0, < 7 from pyproject.toml
  • Simplified behavior: Location.timezone now remains None unless explicitly provided during construction
  • Removed automatic lookup: Eliminated the __post_init__ method that performed timezone lookup from coordinates
  • Updated tests: Removed timezone finder mocking and updated tests to verify the new behavior
  • Added documentation: Comprehensive RELEASE_NOTES.md with migration guide

Breaking Change

This is a breaking change shipped in a patch release because this feature has no known users. The timezone lookup is no longer performed automatically.

Migration for Users Who Need Timezone Lookup

If timezone lookup from coordinates is needed, install timezonefinder separately and implement manual lookup:

# Install: pip install timezonefinder
from timezonefinder import TimezoneFinder
from zoneinfo import ZoneInfo
from frequenz.client.microgrid import Location

tf = TimezoneFinder()
tz_name = tf.timezone_at(lat=52.52, lng=13.405)
timezone = ZoneInfo(tz_name) if tz_name else None
location = Location(latitude=52.52, longitude=13.405, timezone=timezone)

Before/After

Before:

# Automatic timezone lookup
location = Location(latitude=52.52, longitude=13.405)
print(location.timezone)  # ZoneInfo('Europe/Berlin') - looked up automatically

After:

# Explicit timezone only
location = Location(latitude=52.52, longitude=13.405)
print(location.timezone)  # None - no automatic lookup

# Or provide explicitly
location = Location(latitude=52.52, longitude=13.405, timezone=ZoneInfo('Europe/Berlin'))
print(location.timezone)  # ZoneInfo('Europe/Berlin')

Fixes #75.

Copilot AI changed the title [WIP] Remove timezonefinder dependency Remove timezonefinder dependency to reduce package size by 66M+ Jul 31, 2025
Copilot AI requested a review from llucax July 31, 2025 08:24
Copilot finished work on behalf of llucax July 31, 2025 08:24
Copilot finished work on behalf of llucax July 31, 2025 08:40
Copilot AI requested a review from llucax July 31, 2025 08:40
Copy link
Contributor

@llucax llucax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update the RELEASE_NOTES.md file to include the change of behavior and dependencies. Recommend users installing timezonefinder themselves if they need to get a timezone from the coordinates (with a small example). Clarify this change is shipped in a patch release even if there is a breaking change because this feature have no known users.

Copy link
Contributor Author

Copilot AI commented Jul 31, 2025

Please also update the RELEASE_NOTES.md file to include the change of behavior and dependencies. Recommend users installing timezonefinder themselves if they need to get a timezone from the coordi...

Updated RELEASE_NOTES.md with comprehensive documentation of the breaking change, migration guide with code examples, and clarification that this is shipped in a patch release despite being a breaking change because the feature has no known users. Commit 7958389

Copilot AI requested a review from llucax July 31, 2025 08:55
Copilot finished work on behalf of llucax July 31, 2025 08:55
@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:client Affects the client code labels Jul 31, 2025
@llucax llucax marked this pull request as ready for review July 31, 2025 09:03
Copilot AI review requested due to automatic review settings July 31, 2025 09:03
@llucax llucax requested review from a team as code owners July 31, 2025 09:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes the timezonefinder dependency to reduce package size by 66M+ and improve ARM platform compatibility. The automatic timezone lookup functionality in the Location class has been removed as a breaking change due to having no known users.

  • Removed timezonefinder and numpy dependencies (66M+ size reduction)
  • Eliminated automatic timezone lookup from latitude/longitude coordinates
  • Simplified Location class behavior to only use explicitly provided timezone values

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pyproject.toml Removed timezonefinder dependency from project dependencies
src/frequenz/client/microgrid/_metadata.py Removed timezone lookup logic and simplified Location class
tests/test_metadata.py Updated tests to verify new behavior without timezone lookup
RELEASE_NOTES.md Added comprehensive migration guide and breaking change documentation

@llucax llucax changed the title Remove timezonefinder dependency to reduce package size by 66M+ Remove timezonefinder dependency Jul 31, 2025
@llucax llucax enabled auto-merge July 31, 2025 09:19
Remove the `timezonefinder` dependency to significantly reduce package
size by 66M+ and improve ARM platform support, as no pre-built wheels
are available anymore in PyPI.

Signed-off-by: Leandro Lucarella <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@llucax llucax requested a review from Marenz July 31, 2025 13:55
@llucax llucax added this pull request to the merge queue Jul 31, 2025
Merged via the queue into v0.x.x with commit 7f5649d Jul 31, 2025
27 checks passed
@llucax llucax deleted the copilot/fix-75 branch July 31, 2025 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:client Affects the client code part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove timezonefinder dependency

3 participants